package com.cloudeye.logtest.com.cloudeyhe.logtest.actuator;

import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.Selector;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by lafangyuan on 2020/10/28.
 */
@Endpoint(id="costom")
public class CostomActuatorEndpoint {

    public static Map<String,Object> CONFIG  = new HashMap<>();

    static {
        CONFIG.put("appName","myApp");
        CONFIG.put("appVersion","1.0");
    }
    @ReadOperation
    public Map<String,Object> getData(){
        return CONFIG;
    }

    @WriteOperation
    public void writeData(AppInfo appInfo){
        CONFIG.put("appName",appInfo.appName);
        CONFIG.put("appVersion",appInfo.appVersion);
    }

    class AppInfo{
        String appName;
        String appVersion;
        public AppInfo(String appName, String appVersion) {
            this.appName = appName;
            this.appVersion = appVersion;
        }
    }
}
